/**
 * Menu 业务逻辑实现类
 * @author yanwl
 * @date 2014-08-19
 */
package com.chnbst.bstyun.service.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.chnbst.bstyun.core.base.BaseService;
import com.chnbst.bstyun.core.common.helper.DaoHelper;
import com.chnbst.bstyun.model.pojo.Menu;
import com.chnbst.bstyun.service.MenuService;

@Transactional
@Service
public class MenuServiceImpl extends BaseService implements MenuService {
	
	//声明日志对象 logback
	private final static Logger logger = LoggerFactory.getLogger(MenuServiceImpl.class);
	private final static String nameSpace = "com.chnbst.bstyun.mapper.MenuMapper";
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean deleteMenu(Integer menuId) {
		return DaoHelper.delete(nameSpace, "deleteMenu", menuId);
	}
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean insertMenu(Menu menu) {
		return DaoHelper.insert(nameSpace, "insertMenu", menu);
	}
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean updateMenu(Menu menu) {
		return DaoHelper.update(nameSpace, "updateMenu", menu);
	}
	
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public Menu selectMenuByMenuId(Integer menuId) {
		return (Menu)DaoHelper.query(nameSpace, "selectMenuByMenuId", menuId);
	}
	
	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<Menu> selectMenus() {
		return (List<Menu>)DaoHelper.list(nameSpace, "selectMenus", null);
	}
}
